<?php
use common\components\widgets\Datetimepicker;

Datetimepicker::widget(['flag'=>'timepicker','format'=>'Y-m-d']);
?>
<?php $form = \yii\widgets\ActiveForm::begin(['enableAjaxValidation' => true,'enableClientValidation' => false,'options'=>['class'=>'form-validate']]); ?>
    <table width="100%" class="table-form">
        <tr>
            <th class="zx-goods-table" style="width: 40%">学生</th>
            <td style="padding:6px 0;"><?=isset($model->student->name)?$model->student->name:''?></td>
        </tr>
        <tr>
            <td colspan="2" height="10"></td>
        </tr>
        <tr>
            <th class="zx-goods-table" style="width: 40%">课程名称</th>
            <td style="padding:6px 0;"><?=$classattr->course?></td>
        </tr>
        <tr>
            <td colspan="2" height="10"></td>
        </tr>
        <tr>
            <th class="zx-goods-table" style="width: 40%">上课时间</th>
            <td style="padding:6px 0;"><?=$strtime?></td>
        </tr>
        <tr>
            <td colspan="2" height="10"></td>
        </tr>
        <tr>
            <th class="zx-goods-table" style="width: 40%">生成签到方式</th>
            <td><?= $form->field($model, 'types', ['template' => '{input}{error}{hint}'])->radioList([1=>'按已有课次生成',2=>'自定义时间']) ?></td>
        </tr>
        <tr>
            <td colspan="2" height="10"></td>
        </tr>
        <tr id="lesson_id">
            <th class="zx-goods-table" style="width: 40%">选择开始上课的课次</th>
            <td style="display: inline-block;"><?= $form->field($model, 'lesson_id', ['template' => '{input}{error}{hint}'])->widget(\kartik\select2\Select2::className(),['data'=>$lessonLists,'options' => ['placeholder' => '请选择']]) ?></td>
        </tr>
        <tbody id="start_time" style="display: none">
        <tr>
            <th class="zx-goods-table" style="width: 40%">选择时间</th>
            <td><?= $form->field($model, 'start', ['template' => '{input}{error}{hint}'])->textInput(['class'=>'timepicker input-text']) ?></td>
        </tr>
        <tr>
            <th class="zx-goods-table" style="width: 40%">最后一节课日期</th>
            <td><?=date('Y-m-d',$maxLesson->class_date)?></td>
        </tr>
        </tbody>
        <tr>
            <td colspan="2" height="10"></td>
        </tr>
        <tr>
            <th class="zx-goods-table" style="width: 40%">生成签到课次数</th>
            <td style="display: inline-block;"><?= $form->field($model, 'num', ['template' => '{input}{error}{hint}'])->widget(\kartik\select2\Select2::className(),['data'=>$numArr,'options' => ['placeholder' => '请选择']]) ?></td>
        </tr>

    </table>
    <div class="m_top_10 btn" style="display: none">
        <?= \yii\helpers\Html::submitButton('提交', ['class' => "button", 'id' => 'dosubmit']) ?>
    </div>
<?php \yii\widgets\ActiveForm::end(); ?>
<?php
$js = <<<JS
     $(document).on('change','input[type="radio"]',function(){
          var val = $(this).val();
          if(val === '1'){
              $('#lesson_id').css('display','');
              $('#start_time').css('display','none');
          }else {
              $('#lesson_id').css('display','none');
              $('#start_time').css('display','');
          }
     });
JS;
$this->registerJS($js);
?>
